/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.cloudfarming.client.geoviewer;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.IOException;
import nl.cloudfarming.client.model.DataProvider;

/**
 *
 * @author Timon Veenstra
 */
public abstract class BaseLayer implements Layer {

    private Palette palette;
    private final Category category;
    private final String name;
    private final DataProvider dataProvider;

    public static final String PROPERTY_PALETTE = "palette";
    public static final String PROPERTY_INTER_ACTIVE = "interActive";
    private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);


    public BaseLayer(Palette palette, Category category, String name, DataProvider dataProvider) {
        this.palette = palette;
        this.category = category;
        this.name = name;
        this.dataProvider = dataProvider;
    }

   /**
     * Category of the layer
     *
     * @return
     */
    @Override
    public Category getCategory() {
        return this.category;
    }

    /**
     * name of the layer
     *
     * @return
     */
    @Override
    public String getName() {
        return this.name;
    }
    
    

    @Override
    public final void setPalette(Palette palette) {
        assert palette != null;
        changeSupport.firePropertyChange(PROPERTY_PALETTE, this.palette, palette);
        this.palette = palette;
    }

    @Override
    public Palette getPalette() {
        return this.palette;
    }

    /**
     *
     * @param listener
     */
    @Override
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    @Override
    public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(propertyName, listener);
    }

    @Override
    public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(propertyName, listener);
    }


    @Override
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

    protected PropertyChangeSupport getChangeSupport() {
        return changeSupport;
    }

    
    /**
     * override with actions for layerobjects
     *
     * @return
     */
    @Override
    public LayerAction[] getActions(){
        return null;
    }


    @Override
    public DataProvider getDataProvider() {
        return this.dataProvider;
    }


}
